/**
 * Created by 戎大富 on 2018/1/8.
 */
/**
 * 获得搜索参数
 * @param params
 * @returns {Object}
 */
function getSearchParams(params) {
    var searchParams = new Object();
    if (params != undefined) {
        searchParams = params;
    }
    $('.SearchForm').each(function () {
        var param = $(this).val().trim();
        if (param == undefined)
            param = '';
        searchParams[$(this).attr('id')] = param;
    });
    return searchParams;
}


/**
 * 页面自加载
 */
$(function () {
    $('#time').datepicker({
        format : "yyyy-mm-dd",
        todayBtn : "linked",
        autoclose : true,
        todayHighlight : true,
        clearBtn : true
    });
    var cellwidth = ($(".box-content.table-responsive").width() - 55) / 11;
    var psval = $('#datatable_noticeinfo').attr('data-size');
    if (psval == undefined || psval == "") {
        psval = 10;
    }
    /**
     * easyui 生成表格数据
     */
    $('#datatable_noticeinfo').datagrid({
        striped: true,
        remoteSort: false,
        idField: 'n_id',
        collapsible: true,
        fit: false,
        url: 'super/Other/getFeekList',//数据源路径
        loadMsg: '请等待数据载入....',
        pagination: true,
        rownumbers: true,
        fitColumns: true,
        pageSize: psval,
        pageList: [psval, psval * 2, psval * 3, psval * 4, psval * 5],
        columns: [[
            {
                field: 'advice_content',
                title: '内容',
                align: 'center',
                width: cellwidth,
                sortable: true,
                formatter:function(value){
                    if(value!=null){
                        return value.substring(0,10)+'...';
                    }
                }
            }, {
                field: 'advice_link',
                title: '联系方式',
                align: 'center',
                width: cellwidth,
                sortable: true,
            },{
                field: 'user_username',
                title: '用户昵称',
                align: 'center',
                width: cellwidth,
                sortable: true
            }
            ,{
                field: 'user_phone',
                title: '用户手机号码',
                align: 'center',
                width: cellwidth,
                sortable: true
            }
            , {
                field: 'advice_time',
                title: '提交时间',
                align: 'center',
                width: cellwidth,
                sortable: true
            }
            ,
            {
                field: 'advice_id',
                title: '操作',
                align: 'center',
                width: cellwidth,
                sortable: true,
                formatter:function(value,row,index){
                    return html ="<a onclick='ReleaseInfo(this);' style='color:brown;margin-left:5px;text-decoration:none' name='"+value+"' href='JavaScript:;'>查看详情</a><br/>";
                }
            }
        ]],
        onBeforeLoad: function (param) {
            param = getSearchParams(param);
        },
    });
//搜索
    $('#Search').click(function () {
        $('#datatable_noticeinfo').datagrid('reload');
    });
    //清空搜索条件
    $("#Reset").click(function() {
        $('.SearchForm').val('');
    });
});